import { useState } from 'react';
import { AddEdit } from './AddEdit';
import { List } from './List';

export default function () {
  const [page, setPage] = useState<'list' | 'update'>('list');
  const [updateData, setUpdateData] = useState<any>({});
  return page === 'list' ? (
    <List
      onAddEdit={(value) => {
        console.log(value, '----更新了没有');
        setUpdateData(value);
        setPage('update');
      }}
    />
  ) : (
    <AddEdit
      onBack={() => {
        setPage('list');
      }}
      {...updateData}
    ></AddEdit>
  );
}
